package cn.johnyu.service.impl;

import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

//@Service
public class InMemoryMockDetailsService implements ReactiveUserDetailsService {
    @Override
    public Mono<UserDetails> findByUsername(String username) {
        switch (username){
            case "admin":
                return Mono.just(User.withUsername(username).password("{noop}123").roles("ADMIN").build());
            case "john":
                return Mono.just(User.withUsername(username).password("{noop}123").roles("USER").build());
            case "tom":
                return Mono.just(User.withUsername(username).password("{noop}123").roles("ADMIN","USER").build());
            default:
                return Mono.empty();
        }
    }
}
